# config_default.py
#-*- coding:utf-8 -*-

configs = {
    'db': {
        'host': '127.0.0.1',
        'port': 3306,
        'user': 'root',
        'passwd': 'root',
        'db': 'lctbbc_bak',
        'charset':'utf8'
    },
    'session': {
        'secret': 'AwEsOmE'
    }
}

import  MySQLdb
import csv
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
db=MySQLdb.connect(**configs['db'])
print db
cursor=db.cursor()
print cursor
t=cursor.execute("SELECT lct_member.member_name ,sum(lct_order.order_amount) from lct_order left join lct_member on lct_member.member_id=lct_order.buyer_id WHERE lct_order.payment_time BETWEEN UNIX_TIMESTAMP('2016-01-20 00:00:00') AND UNIX_TIMESTAMP('2016-09-22 23:59:59') GROUP BY lct_member.member_id LIMIT 10")
print cursor.fetchall()
# c=[]
# for hotelrs in cursor:
#     c.append(hotelrs)
# print c[2][0]
# csvfile = open('1.csv', 'w') 
# writer = csv.writer(csvfile)
# writer.writerow(c)
# csvfile.close()
# print len(c)
# i=0
# for i < len(c):
#     print c[i]